package cn.hl.sfzy.service.impl;

import cn.hl.sfzy.mapper.AccountMapper;
import cn.hl.sfzy.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountMapper accountMapper;
    @Override
    @Transactional
    public void zz(String a, String b, double c) {
        // 1，先从一个账号中转出 -money
        accountMapper.update(a,-c);
// 默认状态下，一条sql是一个单独的事务，一旦执行则立马改变数据库
//异常测试
//        System.out.println(1/0);
// 2，向一个账号转入 +money
        accountMapper.update(b,c);

    }
}
